home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / read-shift / source / lib / fss_utl2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-25  |  2.2 KB  |  90 lines  |  [TEXT/KAHL]

  1. /* ==========================================
  2.  
  3.     fss_utl2.c    
  4.  
  5.     Copyright (c) 1993,1994 Newport Software Development
  6.     
  7.     You may distribute unmodified copies of this file for
  8.     noncommercial purposes.  You may use this file as a
  9.     reference when writing your own nShell(tm) commands.
  10.     
  11.     All other rights are reserved.
  12.         
  13.    ========================================== */
  14.  
  15. #include <GestaltEqu.h>
  16.  
  17. #include "fss_utl2.proto.h"
  18.  
  19. /* ========================================== */
  20.  
  21. OSErr fss_Create( int gotFSSpec, const FSSpec *spec, OSType creator, OSType type, ScriptCode tag )
  22. {
  23.     OSErr            result;
  24.     HParamBlockRec    block;
  25.         
  26.     if (gotFSSpec)
  27.         return (FSpCreate(spec, creator, type, tag));
  28.     else {
  29.         block.fileParam.ioVRefNum = spec->vRefNum;
  30.         block.fileParam.ioDirID = spec->parID;
  31.         block.fileParam.ioNamePtr = (StringPtr) &(spec->name);
  32.         block.fileParam.ioFVersNum = 0;
  33.         return( PBHCreateSync(&block));
  34.         }
  35. }
  36.  
  37. /* ========================================== */
  38.  
  39. OSErr fss_CreateResFile( int gotFSSpec, const FSSpec *spec, OSType creator, OSType type, ScriptCode tag)
  40. {
  41.     OSErr            result;
  42.     CInfoPBRec        pb;
  43.     
  44.     if (gotFSSpec) {
  45.         result = ResError();
  46.         FSpCreateResFile(spec, creator, type, tag);
  47.         result = ResError();
  48.         }
  49.     else {
  50.         HCreateResFile(spec->vRefNum, spec->parID, spec->name);
  51.         result = ResError();
  52.         if (!result) {
  53.             // set creator and type
  54.             pb.hFileInfo.ioVRefNum = spec->vRefNum;
  55.             pb.hFileInfo.ioDirID = spec->parID;
  56.             pb.hFileInfo.ioNamePtr = (StringPtr) &(spec->name);
  57.             pb.hFileInfo.ioFDirIndex = 0;
  58.             result = PBGetCatInfoSync(&pb);
  59.             if (!result) {
  60.                 pb.hFileInfo.ioFlFndrInfo.fdCreator = creator;
  61.                 pb.hFileInfo.ioFlFndrInfo.fdType = type;
  62.                 pb.hFileInfo.ioDirID = spec->parID;
  63.                 result = PBSetCatInfoSync(&pb);
  64.                 }
  65.             }
  66.         }
  67.         
  68.     return( result );
  69. }
  70.  
  71. /* ========================================== */
  72.  
  73. OSErr fss_Delete(int gotFSSpec, const FSSpec *spec)
  74. {
  75.     HParamBlockRec    pb;
  76.  
  77.     if (gotFSSpec)
  78.         return (FSpDelete(spec));
  79.     else {
  80.         pb.ioParam.ioVRefNum = spec->vRefNum;
  81.         pb.fileParam.ioDirID = spec->parID;
  82.         pb.ioParam.ioNamePtr = (StringPtr) &(spec->name);
  83.         pb.ioParam.ioVersNum = 0;
  84.         return (PBHDeleteSync(&pb));
  85.         }
  86. }
  87.  
  88. /* ========================================== */
  89.     
  90.